//
// Created by work on 24-6-6.
//

#ifndef IOT_PLAT_CRTMODELYKINFO_H
#define IOT_PLAT_CRTMODELYKINFO_H

#include <iot_model_device/CRtModelSigBase.h>
#include <os/miscellany/CConfigs.h>

namespace iotplat {

    class CRtModelYkInfo : public CRtModelSigBase{
    public:

        bool en_write;

        struct SYkValue {
            int value = 0;
            std::string v_descr = "test";
            std::string v_image = "test";
            Json::Value toJson()const {
                Json::Value obj;
                obj["value"] = value;
                obj["v_descr"] = v_descr;
                obj["v_image"] = v_image;
                return obj;
            }

            void fromJson(Json::Value obj) {
                value = obj["value"].asInt();
                v_descr = obj["v_descr"].asString();
                v_image = obj["v_image"].asString();
            }
        };

        enum EModelYkCol{
            EEn_write = 7,
            EValues
        };

        std::vector<SYkValue> values;

        static std::map<CRtModelYkInfo::EModelYkCol, std::string> rtModelYkColToStringMap;
        static std::map<CRtModelYkInfo::EModelYkCol, CValue::EValueType> rtYkDataTypeByField;

    public:
        explicit CRtModelYkInfo();
        Json::Value toJson();
        void fromJson(Json::Value json);
        Json::Value valuesToJson()const;
        void valuesFromJson(const Json::Value &json);
    };

    static const char* t_yk_name = "t_model_yk";

#define YK_ENUM CRtModelYkInfo::EModelYkCol
#define ykFieldName(type)           CRtModelYkInfo::rtModelYkColToStringMap.find(type)->second
#define ykDataTypeByField(type)     CRtModelYkInfo::rtYkDataTypeByField.find(type)->second

} // iotplat

#endif //IOT_PLAT_CRTMODELYKINFO_H
